<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>JavaScript🌞jQuery选择器及元素操作 | 小李博客</title><meta name="keywords" content="JavaScript"><meta name="author" content="小李博客"><meta name="copyright" content="小李博客"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="jQuery 基本概念 jQuery：一款优秀的JavaScript框架库，封装了很多的JavaScript函数。 作用：简化了HTML与JavaScript之间的操作，使得DOM对象、事件处理、动画效果、Ajax等操作的实现语法更加简洁，提高了程序的开发效率，消除很多跨浏览器的兼容问题。   下载jQuery 官方网址：http:&#x2F;&#x2F;jquery.com jQuery官网引用地址最近国内访问会经">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript🌞jQuery选择器及元素操作">
<meta property="og:url" content="http://xiaoliblog.cn/page/js04.html">
<meta property="og:site_name" content="小李博客">
<meta property="og:description" content="jQuery 基本概念 jQuery：一款优秀的JavaScript框架库，封装了很多的JavaScript函数。 作用：简化了HTML与JavaScript之间的操作，使得DOM对象、事件处理、动画效果、Ajax等操作的实现语法更加简洁，提高了程序的开发效率，消除很多跨浏览器的兼容问题。   下载jQuery 官方网址：http:&#x2F;&#x2F;jquery.com jQuery官网引用地址最近国内访问会经">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png">
<meta property="article:published_time" content="2021-01-15T04:25:39.723Z">
<meta property="article:modified_time" content="2021-04-19T13:21:37.864Z">
<meta property="article:author" content="小李博客">
<meta property="article:tag" content="JavaScript">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png"><link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/xiaoliblog/image@6b5e7ef72be1c8973d94e5a9c49accbf775ad820/2021/02/01/c485da031fe0e464d04eaba8a66c4a8f.png"><link rel="canonical" href="http://xiaoliblog.cn/page/js04"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.js" defer></script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: {"appId":"RTG4CPNBLJ","apiKey":"f1745bdad68ceec57653b78244fe332c","indexName":"MyBlogIndex","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":100,"languages":{"author":"作者: 小李博客","link":"链接: ","source":"来源: 小李博客","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'mediumZoom',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-center"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-04-19 21:21:37'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    })(window)</script><link rel="stylesheet" href="/css/MyStyle/MyStyle.css" media="defer" onload="this.media='all'"/><link rel="stylesheet" href="/css/MyStyle/tagStyle.css" media="defer" onload="this.media='all'"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zykjofficial/zykjresource@master/css/font-awesome-animation.min.css" media="defer" onload="this.media='all'"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/plugins.min.css" media="defer" onload="this.media='all'"><meta name="generator" content="Hexo 5.2.0"><link rel="alternate" href="/atom.xml" title="小李博客" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@6b5e7ef72be1c8973d94e5a9c49accbf775ad820/2021/02/01/c485da031fe0e464d04eaba8a66c4a8f.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">210</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">38</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">56</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/box/"><i class="fa-fw fa fa-briefcase"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-book"></i><span> 找文章</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-address-card"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">小李博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/box/"><i class="fa-fw fa fa-briefcase"></i><span> 工具箱</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-book"></i><span> 找文章</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fa fa-address-card"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">JavaScript🌞jQuery选择器及元素操作</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-01-15T04:25:39.723Z" title="发表于 2021-01-15 12:25:39">2021-01-15</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-04-19T13:21:37.864Z" title="更新于 2021-04-19 21:21:37">2021-04-19</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Web%E5%89%8D%E7%AB%AF/">Web前端</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Web%E5%89%8D%E7%AB%AF/JavaScript/">JavaScript</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>14分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="JavaScript🌞jQuery选择器及元素操作"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div><article class="post-content" id="article-container"><h1 id="jQuery"><a href="#jQuery" class="headerlink" title="jQuery"></a>jQuery</h1><ul>
<li>基本概念<ol>
<li>jQuery：一款优秀的JavaScript框架库，封装了很多的JavaScript函数。</li>
<li>作用：简化了HTML与JavaScript之间的操作，使得DOM对象、事件处理、动画效果、Ajax等操作的实现语法更加简洁，提高了程序的开发效率，消除很多跨浏览器的兼容问题。</li>
</ol>
</li>
<li>下载jQuery<ol>
<li>官方网址：<a target="_blank" rel="noopener" href="http://jquery.com/">http://jquery.com</a></li>
<li>jQuery官网引用地址最近国内访问会经常出现打不开的情况，可以戳<a target="_blank" rel="noopener" href="https://www.jq22.com/jquery-info122">jQuery插件库</a></li>
<li><a target="_blank" rel="noopener" href="https://www.runoob.com/jquery/jquery-tutorial.html">jQuery|菜鸟教程</a></li>
</ol>
</li>
<li>引入jQuery<ol>
<li>下载：minified（压缩版，去掉注释和空白行，引入本地下载的jQuery。<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;jquery-1.12.4.min.js&quot;</span>&gt;</span><span class="handlebars"><span class="xml"><span class="tag">&lt;/<span class="name">scirpt</span>&gt;</span></span></span></span><br></pre></td></tr></table></figure></li>
<li>CDN：内容分发网络，通过CDN的优势可以加快jQuery文件的访问速度<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">script</span>   <span class="attr">src</span>=<span class="string">&quot;https://code.jquery.com/jquery-3.4.1.min.js&quot;</span> &gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
</ol>
</li>
<li>使用jQuery</li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">在HTML页面中创建&lt;h2&gt;元素，该元素含有文本“测试”和“居中”属性的。</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="comment">//html实现</span></span><br><span class="line">&lt;h2 align=‘center’&gt;测试&lt;/h2&gt;</span><br><span class="line"><span class="comment">//JS实现</span></span><br><span class="line"><span class="keyword">var</span> h2 = <span class="built_in">document</span>.createElement(<span class="string">&#x27;h2&#x27;</span>); 	</span><br><span class="line"><span class="keyword">var</span> text = <span class="built_in">document</span>.createTextNode(‘测试’); </span><br><span class="line"><span class="keyword">var</span> attr = <span class="built_in">document</span>.createAttribute(<span class="string">&#x27;align&#x27;</span>);	</span><br><span class="line">attr.value = ‘center’; 			</span><br><span class="line">h2.setAttributeNode(attr);  	</span><br><span class="line">h2.appendChild(text); 		</span><br><span class="line"><span class="built_in">document</span>.querySelector(<span class="string">&#x27;body&#x27;</span>).appendChild(h2);</span><br><span class="line"><span class="comment">//jQuery实现</span></span><br><span class="line"><span class="comment">//美元符号$表示jQuery类，也就是说&quot;$()&quot;等价于&quot;jQuery()&quot;,即jQuery的构造函数。</span></span><br><span class="line">$(<span class="string">&#x27;&lt;h2 align=&quot;center&quot;&gt;测试&lt;/h2&gt;&#x27;</span>).appendTo(<span class="string">&#x27;body&#x27;</span>);</span><br></pre></td></tr></table></figure>

<h1 id="jQuery选择器"><a href="#jQuery选择器" class="headerlink" title="jQuery选择器"></a>jQuery选择器</h1><ul>
<li><p><strong>语法：$(选择器)</strong></p>
</li>
<li><p>基本选择器、层级选择器</p>
</li>
<li><p>基本过滤选择器、内容选择器</p>
</li>
<li><p>可见性选择器、属性选择器</p>
</li>
<li><p>子元素选择器、表单选择器</p>
</li>
</ul>
<h2 id="基本选择器"><a href="#基本选择器" class="headerlink" title="基本选择器"></a>基本选择器</h2><ul>
<li>基本选择器常用的有标签选择器、类选择器和ID选择器</li>
</ul>
<table>
<thead>
<tr>
<th align="center">CSS选择器</th>
<th align="center">功能描述</th>
<th align="center">示例</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>li&#123;color:red&#125;</code></td>
<td align="center">根据指定元素名匹配所有元素</td>
<td align="center">${“li”}</td>
</tr>
<tr>
<td align="center"><code>.bar&#123;color:red&#125;</code></td>
<td align="center">根据指定类名匹配所有元素</td>
<td align="center">${“.bar”}</td>
</tr>
<tr>
<td align="center"><code>#btn&#123;color:red&#125;</code></td>
<td align="center">根据指定id匹配一个元素</td>
<td align="center">${“#bar}”</td>
</tr>
<tr>
<td align="center"><code>li,.bar,#btn&#123;color:red&#125;</code></td>
<td align="center">同时获取多个元素</td>
<td align="center">${“li,p,div”}</td>
</tr>
</tbody></table>
<img src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/25/b0ece8129f371bfe621892437397d7a0.png" width="70%">

<h2 id="层级选择器"><a href="#层级选择器" class="headerlink" title="层级选择器"></a>层级选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">示例</th>
<th align="center">功能描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>selector selector1</code></td>
<td align="center"><code>$(&quot;div .test&quot;)</code></td>
<td align="center">选取&lt;div&gt;下所有class名为test的元素（多级）</td>
</tr>
<tr>
<td align="center"><code>parent &gt; child</code></td>
<td align="center"><code>$(&quot;.box &gt; .con&quot;)</code></td>
<td align="center">选取class名为box下的所有class名为con的子元素（一级）</td>
</tr>
<tr>
<td align="center"><code>prev + next</code></td>
<td align="center"><code>$(&quot;div + .title&quot;)</code></td>
<td align="center">获取紧邻&lt;div&gt;的下一个class名为title的兄弟节点</td>
</tr>
<tr>
<td align="center"><code>prev ~ siblings</code></td>
<td align="center"><code>$(&quot;.bar ~ li&quot;)</code></td>
<td align="center">获取class名为bar的元素后的所有同级元素节点&lt;li&gt;</td>
</tr>
</tbody></table>
<img src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/25/991e6bf8bb02ade1e9fb757b2dabbcc3.png" widht="60%">

<h2 id="基本过滤选择器"><a href="#基本过滤选择器" class="headerlink" title="基本过滤选择器"></a>基本过滤选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">示例</th>
<th align="center">功能描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>:first</code></td>
<td align="center"><code>$(&quot;li : first&quot;)</code></td>
<td align="center">获取第1个&lt;li&gt;元素</td>
</tr>
<tr>
<td align="center"><code>:last</code></td>
<td align="center"><code>$(&quot;li : last&quot;)</code></td>
<td align="center">获取最后1个&lt;li&gt;元素</td>
</tr>
<tr>
<td align="center"><code>:even</code></td>
<td align="center"><code>$(&quot;li :even&quot;)</code></td>
<td align="center">获取所有li元素中，索引为偶数的奇数行数据,从0开始</td>
</tr>
<tr>
<td align="center"><code>:odd</code></td>
<td align="center"><code>$(&quot;li :odd&quot;)</code></td>
<td align="center">获取所有li元素中，索引为奇数数的偶数行数据，从0开始</td>
</tr>
<tr>
<td align="center"><code>:eq(index)</code></td>
<td align="center"><code>$(&quot;li:eq(3)&quot;)</code></td>
<td align="center">获取索引为3的li元素</td>
</tr>
<tr>
<td align="center"><code>:gt(index)</code></td>
<td align="center"><code>$(&quot;li :eq(3)&quot;)</code></td>
<td align="center">获取索引大于3的li元素</td>
</tr>
<tr>
<td align="center"><code>:It(index)</code></td>
<td align="center"><code>$(&quot;li :It(3)&quot;)</code></td>
<td align="center">获取索引小于3的li元素</td>
</tr>
<tr>
<td align="center"><code>:not(seletor)</code></td>
<td align="center"><code>$(&quot;li :not(li:qe(3))&quot;)</code></td>
<td align="center">获取除指定选择器外的其他元素，获取除索引为3的li元素</td>
</tr>
<tr>
<td align="center"><code>:focus</code></td>
<td align="center"><code>$(&quot;inputs:focus&quot;)</code></td>
<td align="center">匹配当前获取焦点的input元素</td>
</tr>
<tr>
<td align="center"><code>:animated</code></td>
<td align="center"><code>$(&quot;div:not(:animated)&quot;)</code></td>
<td align="center">匹配当前没有执行动画的div元素</td>
</tr>
</tbody></table>
<h2 id="内容选择器"><a href="#内容选择器" class="headerlink" title="内容选择器"></a>内容选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">功能描述</th>
<th align="center">示例</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>:contains(text)</code></td>
<td align="center">获取内容包含1text文本的元素</td>
<td align="center"><code>&amp;(&quot;li:contains(&#39;js&#39;)&quot;)</code>获取内容中含’js’的li元素</td>
</tr>
<tr>
<td align="center"><code>:empty</code></td>
<td align="center">获取内容为空的元素</td>
<td align="center"><code>$(&quot;li:empty&quot;)</code>获取内容为空的li元素</td>
</tr>
<tr>
<td align="center"><code>:has(selector)</code></td>
<td align="center">获取内容包含指定选择器元素</td>
<td align="center"><code>$(&quot;li:has(&#39;a&#39;)&quot;)</code>获取内容中含a元素的所有li元素</td>
</tr>
<tr>
<td align="center"><code>:parent</code></td>
<td align="center">获取内容不为空的元素(特殊)</td>
<td align="center"><code>$(&quot;li:parent&quot;)</code>获取内容不为空的li元素</td>
</tr>
</tbody></table>
<h2 id="可见性选择器"><a href="#可见性选择器" class="headerlink" title="可见性选择器"></a>可见性选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">功能描述</th>
<th align="center">示例</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>:hidden</code></td>
<td align="center">获取所有隐藏元素</td>
<td align="center"><code>$(&quot;li:hidden&quot;)</code>获取所有隐藏的li元素</td>
</tr>
<tr>
<td align="center"><code>:visible</code></td>
<td align="center">获取所有可见元素</td>
<td align="center"><code>$(&quot;li:visible&quot;)</code>获取所有可见的li元素</td>
</tr>
</tbody></table>
<h2 id="属性选择器"><a href="#属性选择器" class="headerlink" title="属性选择器"></a>属性选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">功能描述</th>
<th align="center">示例</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>[attr]</code></td>
<td align="center">获取具体指定属性的元素</td>
<td align="center"><code>$(&quot;div[class]&quot;)</code>获取含有class属性的所有div元素</td>
</tr>
<tr>
<td align="center"><code>[attr=value]</code></td>
<td align="center">获取属性值等于value的元素</td>
<td align="center"><code>$(&quot;div[class=current]&quot;)</code>获取class等于current的所有div元素</td>
</tr>
<tr>
<td align="center"><code>[attr！=value]</code></td>
<td align="center">获取属性值不等于value的元素</td>
<td align="center"><code>$(&quot;div[class！=current]&quot;)</code>获取class不等于current的所有div元素</td>
</tr>
<tr>
<td align="center"><code>[attr^=value]</code></td>
<td align="center">获取属性值以value开始的元素</td>
<td align="center"><code>$(&quot;div[class^box]&quot;)</code>获取class以box开始的所有div元素</td>
</tr>
<tr>
<td align="center"><code>[attr$=value]</code></td>
<td align="center">获取属性值以value结尾的元素</td>
<td align="center"><code>$(&quot;div[class$box]&quot;)</code>获取class以box结尾的所有div元素</td>
</tr>
<tr>
<td align="center"><code>[attr*=value]</code></td>
<td align="center">获取属性值包含value的元素</td>
<td align="center"><code>$(&quot;div[class\*=&#39;-&#39;]&quot;)</code>获取class含有’-‘的所有div元素</td>
</tr>
<tr>
<td align="center"><code>[attr~=value]</code></td>
<td align="center">获取元素的属性值包含一个value，以空格隔开</td>
<td align="center"><code>$(&quot;div[class~=&#39;box&#39;]&quot;)</code>获取class属性值等于’box’或通过空格分隔并含有box的div元素，如”t box”</td>
</tr>
<tr>
<td align="center"><code>[attr1][attr2]...[attrN]</code></td>
<td align="center">获取同时拥有多个属性的元素</td>
<td align="center"><code>$(&quot;input[id][name$=&#39;usr&#39;]&quot;)</code>获取同时含有id属性和属性值以usr结尾的name属性的input元素</td>
</tr>
</tbody></table>
<h2 id="子元素选择器"><a href="#子元素选择器" class="headerlink" title="子元素选择器"></a>子元素选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">功能描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>:nth-child(index/even/odd/公式)</code></td>
<td align="center">索引index默认从1开始，匹配指定index索引、偶数、奇书、或符合指定公式(如2n,n默认从0开始)的子元素</td>
</tr>
<tr>
<td align="center"><code>:first-child</code></td>
<td align="center">获取第一个子元素</td>
</tr>
<tr>
<td align="center"><code>:last-child</code></td>
<td align="center">获取最后一个子元素</td>
</tr>
<tr>
<td align="center"><code>:only-child</code></td>
<td align="center">如果当前元素时唯一的子元素，则匹配</td>
</tr>
<tr>
<td align="center"><code>:nth-last-child(index/even/odd/公式)</code></td>
<td align="center">选择所有它们父元素的第n个子元素，计数从最后一个元素开始到第一个</td>
</tr>
<tr>
<td align="center"><code>:nth-of-type(index/even/odd/公式)</code></td>
<td align="center">选择同一个父元素之下，并且标签名相同的子元素中的第n个子元素</td>
</tr>
<tr>
<td align="center"><code>:first-of-type</code></td>
<td align="center">选择所有相同的元素名称的第一个子元素</td>
</tr>
<tr>
<td align="center"><code>:last-of-type</code></td>
<td align="center">选择所有相同的元素名称的最后一个子元素</td>
</tr>
<tr>
<td align="center"><code>:only-of-type</code></td>
<td align="center">选择所有没有兄弟元素，且具有相同的元素名称的元素</td>
</tr>
<tr>
<td align="center"><code>:nth-last-of-type(index/even/odd/公式)</code></td>
<td align="center">选择所有它们的父级元素的第n个子元素，计数从最后一个元素开始到第一个</td>
</tr>
</tbody></table>
<h2 id="表单选择器"><a href="#表单选择器" class="headerlink" title="表单选择器"></a>表单选择器</h2><table>
<thead>
<tr>
<th align="center">选择器</th>
<th align="center">功能描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>:input</code></td>
<td align="center">获取页面中的所有表单元素，包含select元素和textarea元素</td>
</tr>
<tr>
<td align="center"><code>:text</code></td>
<td align="center">选取页面中的所有文本框</td>
</tr>
<tr>
<td align="center"><code>:password</code></td>
<td align="center">选取所有的密码框</td>
</tr>
<tr>
<td align="center"><code>:radio</code></td>
<td align="center">选取所有的单选按钮</td>
</tr>
<tr>
<td align="center"><code>:checkbox</code></td>
<td align="center">选取所有的复选框</td>
</tr>
<tr>
<td align="center"><code>:submit</code></td>
<td align="center">获取submit提交按钮</td>
</tr>
<tr>
<td align="center"><code>:reset</code></td>
<td align="center">获取reset重置按钮</td>
</tr>
<tr>
<td align="center"><code>:image</code></td>
<td align="center">获取type=”image”的图像域</td>
</tr>
<tr>
<td align="center"><code>:button</code></td>
<td align="center">获取button按钮，包括button标签和type=”button”</td>
</tr>
<tr>
<td align="center"><code>:file</code></td>
<td align="center">获取type=”file”的文件域</td>
</tr>
<tr>
<td align="center"><code>:hidden</code></td>
<td align="center">获取隐藏表单项</td>
</tr>
<tr>
<td align="center"><code>:enabled</code></td>
<td align="center">获取所有可用表单元素</td>
</tr>
<tr>
<td align="center"><code>:disabled</code></td>
<td align="center">获取所有不可用表单元素</td>
</tr>
<tr>
<td align="center"><code>:checked</code></td>
<td align="center">获取所有选中的表单元素，主要针对radio和checkbox</td>
</tr>
<tr>
<td align="center"><code>:selected</code></td>
<td align="center">获取所有可用表单元素，主要针对select</td>
</tr>
</tbody></table>
<h2 id="元素筛选函数"><a href="#元素筛选函数" class="headerlink" title="元素筛选函数"></a>元素筛选函数</h2><table>
<thead>
<tr>
<th align="center">语法</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>$(&quot;ul&quot;).find(&quot;span&quot;)</code></td>
<td align="center">返回&lt;ul&gt; 后代中所有的&lt;span&gt; 元素</td>
</tr>
<tr>
<td align="center"><code>$(&quot;ul&quot;).siblings(&quot;span&quot;))</code></td>
<td align="center">返回与&lt;ul&gt; 同级的所有的 &lt;span&gt; 元素</td>
</tr>
<tr>
<td align="center"><code>$(&quot;ul&quot;).next(&quot;span&quot;))</code></td>
<td align="center">匹配&lt;ul&gt;紧邻的同级的下一个&lt;span&gt;元素</td>
</tr>
<tr>
<td align="center"><code>$(&quot;ul&quot;). prev(&quot;span&quot;))</code></td>
<td align="center">匹配&lt;ul&gt;紧邻的同级的上一个&lt;span&gt;元素</td>
</tr>
</tbody></table>
<img src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/25/ce1673e1b45dc9421d7a6c4652b96f37.png" width="60%">

<ul>
<li>获取第三层的第一个li</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(<span class="string">&#x27;#fold&gt;ul&gt;li:first&#x27;</span>)</span><br></pre></td></tr></table></figure>

<ul>
<li>通过上面的li，获得其下class为wrap的元素</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(<span class="string">&#x27;#fold&gt;ul&gt;li:first&#x27;</span>).find(<span class="string">&#x27;.wrap&#x27;</span>);</span><br></pre></td></tr></table></figure>

<h1 id="元素操作"><a href="#元素操作" class="headerlink" title="元素操作"></a>元素操作</h1><h2 id="元素遍历"><a href="#元素遍历" class="headerlink" title="元素遍历"></a>元素遍历</h2><ul>
<li><code>each()</code>方法可以对元素进行遍历</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">li</span>&gt;</span>PHP<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">li</span>&gt;</span>IOS<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">li</span>&gt;</span>JAVA<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">li</span>&gt;</span>JS<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript"><span class="comment">//each参数：回调函数</span></span></span><br><span class="line"><span class="javascript">   $(<span class="string">&#x27;li&#x27;</span>).each(<span class="function"><span class="keyword">function</span>(<span class="params">index,element</span>)</span>&#123;</span></span><br><span class="line"><span class="javascript">      <span class="built_in">console</span>.og(<span class="string">&quot;第&quot;</span>+(index+<span class="number">1</span>)+<span class="string">&#x27;个:&#x27;</span>+$(element).text());</span></span><br><span class="line">   &#125;);</span><br><span class="line"><span class="javascript"><span class="comment">//each：遍历选择器匹配到的所有&lt;li&gt;元素</span></span></span><br><span class="line"><span class="javascript"><span class="comment">//index：当前元素的索引位置</span></span></span><br><span class="line"><span class="javascript"><span class="comment">//element：当前元素</span></span></span><br><span class="line"><span class="javascript"><span class="comment">//text():函数，元素的文本</span></span></span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">/*</span><br><span class="line">第1个:PHP</span><br><span class="line">第2个:IOS</span><br><span class="line">第3个:JAVA</span><br><span class="line">第4个:JS</span><br><span class="line">*/</span><br></pre></td></tr></table></figure>
<h2 id="元素内容"><a href="#元素内容" class="headerlink" title="元素内容"></a>元素内容</h2><table>
<thead>
<tr>
<th align="center">语法</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>html()</code></td>
<td align="center">获取第一个匹配元素的HTML内容</td>
</tr>
<tr>
<td align="center"><code>html(content)</code></td>
<td align="center">设置第一个匹配元素的HTML内容</td>
</tr>
<tr>
<td align="center"><code>text()</code></td>
<td align="center">获取所有匹配元素包含的文本内容组合起来的文本</td>
</tr>
<tr>
<td align="center"><code>text(content)</code></td>
<td align="center">设置所有匹配元素的文本内容</td>
</tr>
<tr>
<td align="center"><code>val()</code></td>
<td align="center">获取表单元素的value值</td>
</tr>
<tr>
<td align="center"><code>val(value)</code></td>
<td align="center">设置表单元素的value值</td>
</tr>
</tbody></table>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span> <span class="meta-keyword">PUBLIC</span> <span class="meta-string">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span class="meta-string">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span class="attr">xml:lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">&quot;Content-Type&quot;</span> <span class="attr">content</span>=<span class="string">&quot;text/html;charset=UTF-8&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>Document<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span>PHP<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span>ios<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span>java<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span>js<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;jquery-3.4.1.min.js&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript">        $(<span class="string">&#x27;li&#x27;</span>).each(<span class="function"><span class="keyword">function</span>(<span class="params">index,element</span>)</span>&#123;</span></span><br><span class="line"><span class="javascript">            $(element).text(<span class="string">&#x27;修改后的内容&#x27;</span> + index);</span></span><br><span class="line">        &#125;);</span><br><span class="line"><span class="javascript">        $(<span class="string">&#x27;li&#x27;</span>).each(<span class="function"><span class="keyword">function</span>(<span class="params">index,element</span>)</span>&#123;</span></span><br><span class="line"><span class="javascript">            <span class="built_in">console</span>.log(<span class="string">&quot;第&quot;</span> + (index+<span class="number">1</span>) + <span class="string">&#x27;个:&#x27;</span></span></span><br><span class="line"><span class="javascript">                + $(element).text());</span></span><br><span class="line">        &#125;);</span><br><span class="line">    <span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/25/63efebe8bea84d084a689d34e0d14a17.png"></p>
<h2 id="元素样式"><a href="#元素样式" class="headerlink" title="元素样式"></a>元素样式</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> ele=$(<span class="string">&#x27;div&#x27;</span>);</span><br><span class="line">ele.css(&#123;<span class="attr">border</span>:<span class="string">&#x27;2px solid black&#x27;</span>,<span class="attr">backgroundColor</span>:<span class="string">&#x27;#ccc&#x27;</span>&#125;);	</span><br><span class="line"><span class="keyword">var</span> w=ele.css(<span class="string">&#x27;width&#x27;</span>);</span><br><span class="line"><span class="keyword">var</span> h=ele.css(<span class="string">&#x27;height&#x27;</span>);</span><br><span class="line">ele.css(<span class="string">&#x27;width&#x27;</span>,<span class="string">&#x27;200px&#x27;</span>);</span><br><span class="line">ele.css(<span class="string">&#x27;height&#x27;</span>,<span class="string">&#x27;200px&#x27;</span>);</span><br></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th align="center">语法</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>css(name)</code></td>
<td align="center">name:样式名称，获得样式的值</td>
</tr>
<tr>
<td align="center"><code>css(properties)</code></td>
<td align="center">properties：键值对形式的对象，设置样式值</td>
</tr>
<tr>
<td align="center"><code>css(name,value)</code></td>
<td align="center">设置样式的值</td>
</tr>
<tr>
<td align="center"><code>width()/width(value)</code></td>
<td align="center">获取/设置第一个匹配元素的当前宽度值</td>
</tr>
<tr>
<td align="center"><code>height()/height(value)</code></td>
<td align="center">获取/设置第一个匹配元素的当前高度值</td>
</tr>
<tr>
<td align="center"><code>offset()</code></td>
<td align="center">获取元素的位置，返回的是一个对象，包含left和top属性</td>
</tr>
<tr>
<td align="center"><code>offset(properties)</code></td>
<td align="center">利用对象设置元素的位置，必须包含left和top属性</td>
</tr>
</tbody></table>
<h2 id="元素属性"><a href="#元素属性" class="headerlink" title="元素属性"></a>元素属性</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$(element).prop(<span class="string">&#x27;checked&#x27;</span>,<span class="literal">false</span>);</span><br></pre></td></tr></table></figure>
<table>
<thead>
<tr>
<th align="center">语法</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>attr(name)</code></td>
<td align="center">取得第一个匹配元素的属性值，否则返回undefined</td>
</tr>
<tr>
<td align="center"><code>attr(properties)</code></td>
<td align="center">将一个键值对形式的对象设置为所有匹配元素的属性</td>
</tr>
<tr>
<td align="center"><code>attr(name,value)</code></td>
<td align="center">为所有匹配的元素设置一个属性值</td>
</tr>
<tr>
<td align="center"><code>removeAtrre(name)</code></td>
<td align="center">从每一个匹配的元素中删除一个属性</td>
</tr>
<tr>
<td align="center"><code>prop(name)</code></td>
<td align="center">取得第一个匹配元素的属性值，否则返回undefined</td>
</tr>
<tr>
<td align="center"><code>prop(properties)</code></td>
<td align="center">将一个键值对形式的对象设置为所有匹配元素的属性</td>
</tr>
<tr>
<td align="center"><code>prop(name,value)</code></td>
<td align="center">为所有匹配的元素设置一个属性值</td>
</tr>
</tbody></table>
<ul>
<li><code>attr()</code>和<code>prop()</code>只能获取第一个匹配元素的属性值<ul>
<li>操作状态，如checked、selected、disabled时(有true/false)用prop；其它用attr。</li>
</ul>
</li>
</ul>
<h2 id="元素基本属性"><a href="#元素基本属性" class="headerlink" title="元素基本属性"></a>元素基本属性</h2><table>
<thead>
<tr>
<th align="center">语法</th>
<th align="center">作用</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><code>addClass(class)</code></td>
<td align="center">追加样式</td>
<td align="center">为每个匹配的元素追加指定的类名</td>
</tr>
<tr>
<td align="center"><code>removeClass(class)</code></td>
<td align="center">移除样式</td>
<td align="center">从所有匹配的元素中删除全部或者指定的类</td>
</tr>
<tr>
<td align="center"><code>toggleClass(class)</code></td>
<td align="center">切换样式</td>
<td align="center">判断指定类是否存在，存在则删除，不存在则添加</td>
</tr>
<tr>
<td align="center"><code>hasClass(class)</code></td>
<td align="center">判断样式</td>
<td align="center">判断元素是否具有class样式</td>
</tr>
</tbody></table>
<h1 id="折叠菜单"><a href="#折叠菜单" class="headerlink" title="折叠菜单"></a>折叠菜单</h1><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;utf-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">http-equiv</span>=<span class="string">&quot;X-UA-Compatible&quot;</span> <span class="attr">content</span>=<span class="string">&quot;IE=edge&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span><span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;jquery-3.4.1.js&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">&quot;stylesheet&quot;</span> <span class="attr">href</span>=<span class="string">&quot;&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="css">      <span class="selector-tag">ul</span>&#123;<span class="attribute">list-style</span>:none;<span class="attribute">padding</span>:<span class="number">0</span>;<span class="attribute">margin</span>:<span class="number">0</span>&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-tag">div</span>&#123;<span class="attribute">width</span>:<span class="number">150px</span>;<span class="attribute">border</span>:<span class="number">1px</span> solid <span class="number">#515E7B</span>;<span class="attribute">margin</span>:<span class="number">10px</span>;&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-tag">div</span> <span class="selector-tag">li</span>&#123;<span class="attribute">background</span>:<span class="number">#515E7B</span>;<span class="attribute">border-bottom</span>:<span class="number">1px</span> solid <span class="number">#fff</span>;&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-tag">div</span> <span class="selector-tag">li</span> <span class="selector-tag">a</span>&#123;<span class="attribute">text-decoration</span>:none;<span class="attribute">color</span>:<span class="number">#fff</span>;<span class="attribute">font-size</span>:<span class="number">16px</span>;<span class="attribute">height</span>:<span class="number">40px</span>;<span class="attribute">line-height</span>:<span class="number">40px</span>;<span class="attribute">padding-left</span>:<span class="number">10px</span>;&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-tag">div</span> <span class="selector-tag">li</span> <span class="selector-tag">a</span><span class="selector-pseudo">:hover</span>&#123;<span class="attribute">text-decoration</span>:underline;&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-class">.wrap</span> &#123;<span class="attribute">width</span>:<span class="number">150px</span>;<span class="attribute">display</span>:none;&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-class">.wrap</span> <span class="selector-tag">li</span>&#123;<span class="attribute">background</span>: <span class="number">#fff</span>;<span class="attribute">margin</span>: <span class="number">0</span>;&#125;</span></span><br><span class="line"><span class="css">      <span class="selector-class">.wrap</span> <span class="selector-tag">li</span> <span class="selector-tag">a</span>&#123;<span class="attribute">color</span>:<span class="number">#3B475F</span>;<span class="attribute">font-size</span>:<span class="number">12px</span>;&#125;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">&quot;fold&quot;</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>信息管理<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">ul</span> <span class="attr">class</span>=<span class="string">&quot;wrap&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>未读信息<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>已读信息<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>信息列表<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>商品管理<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">ul</span> <span class="attr">class</span>=<span class="string">&quot;wrap&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>商品添加<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>商品列表<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>商品分类<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>用户管理<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">ul</span> <span class="attr">class</span>=<span class="string">&quot;wrap&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>权限设置<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>用户列表<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span>重置密码<span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript">        <span class="comment">// 默认第一个显示：css--display:block</span></span></span><br><span class="line"><span class="javascript">        $(<span class="string">&quot;.wrap:first&quot;</span>).css(<span class="string">&#x27;display&#x27;</span>,<span class="string">&#x27;block&#x27;</span>);</span></span><br><span class="line"><span class="javascript">        <span class="comment">//添加点击事件，当前显示,其它隐藏</span></span></span><br><span class="line"><span class="javascript">        $(<span class="string">&quot;#fold&gt;ul&gt;li&quot;</span>).click(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;   <span class="comment">//无需遍历，直接添加事件</span></span></span><br><span class="line"><span class="javascript">            $(<span class="built_in">this</span>).siblings(<span class="string">&#x27;li&#x27;</span>).find(<span class="string">&#x27;.wrap&#x27;</span>).css(&#123;<span class="attr">display</span>:<span class="string">&#x27;none&#x27;</span>&#125;);</span></span><br><span class="line"><span class="javascript">            $(<span class="built_in">this</span>).find(<span class="string">&#x27;.wrap&#x27;</span>).css(&#123;<span class="attr">display</span>:<span class="string">&#x27;block&#x27;</span>&#125;);</span></span><br><span class="line">            &#125;</span><br><span class="line">        );</span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><img src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/25/91b2836348482ddd0439b8c1de7080b9.png"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">小李博客</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://xiaoliblog.cn">https://xiaoliblog.cn</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://xiaoliblog.cn" target="_blank">小李博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/JavaScript/">JavaScript</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="/img/wechat.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.png" target="_blank"><img class="post-qr-code-img" src="/img/alipay.png" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/page/os02.html"><img class="prev-cover" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@46194ca18065ae5d399864564e6f718045a04d48/2021/01/24/1a8d51f216a11fa2f3a7fb50049f1f1d.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">操作系统⚡概述</div></div></a></div><div class="next-post pull-right"><a href="/page/js01.html"><img class="next-cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">JavaScript🌞Ajax</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/page/js06.html" title="JavaScript🌞函数"><img class="cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-15</div><div class="title">JavaScript🌞函数</div></div></a></div><div><a href="/page/js05.html" title="JavaScript🌞对象"><img class="cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-15</div><div class="title">JavaScript🌞对象</div></div></a></div><div><a href="/page/js08.html" title="JavaScript🌞数组"><img class="cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-15</div><div class="title">JavaScript🌞数组</div></div></a></div><div><a href="/page/js09.html" title="JavaScript🌞语法基础"><img class="cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-15</div><div class="title">JavaScript🌞语法基础</div></div></a></div><div><a href="/page/js01.html" title="JavaScript🌞Ajax"><img class="cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-15</div><div class="title">JavaScript🌞Ajax</div></div></a></div><div><a href="/page/js02.html" title="JavaScript🌞BOM"><img class="cover" src="https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/12/26/527e6ac3b16d4038ba3bd09e3b174450.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-01-15</div><div class="title">JavaScript🌞BOM</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@6b5e7ef72be1c8973d94e5a9c49accbf775ad820/2021/02/01/c485da031fe0e464d04eaba8a66c4a8f.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">小李博客</div><div class="author-info__description">越努力，越幸运！</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">210</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">38</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">56</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xiaoliblog"><i class="fab fa-github"></i><span>博主的GitHub首页</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitee.com/xiaoliblog" target="_blank" title="Gitee"><i class="iconfont icon-gitee card_icon_gitee"></i></a><a class="social-icon" href="https://space.bilibili.com/390969485" target="_blank" title="BiliBili"><i class="iconfont icon-bilibili card_icon_bilibili"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=2312057536&amp;site=CSDN&amp;menu=yes" target="_blank" title="QQ"><i class="iconfont icon-qq card_icon_qq"></i></a><a class="social-icon" href="https://github.com/xiaoliblog" target="_blank" title="GitHub"><i class="iconfont icon-git card_icon_git"></i></a><a class="social-icon" href="https://blog.csdn.net/qq_43266250?spm=1010.2135.3001.5113" target="_blank" title="CSDN"><i class="iconfont icon-csdn card_icon_csdn"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">正在考研备考中💦</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#jQuery"><span class="toc-number">1.</span> <span class="toc-text">jQuery</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#jQuery%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.</span> <span class="toc-text">jQuery选择器</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.1.</span> <span class="toc-text">基本选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B1%82%E7%BA%A7%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.2.</span> <span class="toc-text">层级选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E8%BF%87%E6%BB%A4%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.3.</span> <span class="toc-text">基本过滤选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%86%85%E5%AE%B9%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.4.</span> <span class="toc-text">内容选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%AF%E8%A7%81%E6%80%A7%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.5.</span> <span class="toc-text">可见性选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B1%9E%E6%80%A7%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.6.</span> <span class="toc-text">属性选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AD%90%E5%85%83%E7%B4%A0%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.7.</span> <span class="toc-text">子元素选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%A1%A8%E5%8D%95%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">2.8.</span> <span class="toc-text">表单选择器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E7%AD%9B%E9%80%89%E5%87%BD%E6%95%B0"><span class="toc-number">2.9.</span> <span class="toc-text">元素筛选函数</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E6%93%8D%E4%BD%9C"><span class="toc-number">3.</span> <span class="toc-text">元素操作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E9%81%8D%E5%8E%86"><span class="toc-number">3.1.</span> <span class="toc-text">元素遍历</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E5%86%85%E5%AE%B9"><span class="toc-number">3.2.</span> <span class="toc-text">元素内容</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E6%A0%B7%E5%BC%8F"><span class="toc-number">3.3.</span> <span class="toc-text">元素样式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E5%B1%9E%E6%80%A7"><span class="toc-number">3.4.</span> <span class="toc-text">元素属性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%83%E7%B4%A0%E5%9F%BA%E6%9C%AC%E5%B1%9E%E6%80%A7"><span class="toc-number">3.5.</span> <span class="toc-text">元素基本属性</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%8A%98%E5%8F%A0%E8%8F%9C%E5%8D%95"><span class="toc-number">4.</span> <span class="toc-text">折叠菜单</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/page/project01.html" title="前端实例🥳响应式网站首页"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@c19917500ab083c77c7613263ba7ee74d5a08ae6/2021/04/30/469f30b141d73fa0fc4c962662d5813f.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="前端实例🥳响应式网站首页"/></a><div class="content"><a class="title" href="/page/project01.html" title="前端实例🥳响应式网站首页">前端实例🥳响应式网站首页</a><time datetime="2021-04-30T11:50:53.094Z" title="发表于 2021-04-30 19:50:53">2021-04-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/WeChatpay.html" title="微信支付对接"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@f2f670b92ea149650ffa7834354fc90284f2f44a/2021/04/29/5bdc9b381a06193d27cf2fb7c2fb608a.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="微信支付对接"/></a><div class="content"><a class="title" href="/page/WeChatpay.html" title="微信支付对接">微信支付对接</a><time datetime="2021-04-29T12:20:48.070Z" title="发表于 2021-04-29 20:20:48">2021-04-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/Alipay.html" title="支付宝支付对接"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@61a9b6a6e09e4bda38bb08e3104b717885beaee5/2021/04/29/c3fa51f9cf14e90d9e5a7aa8814dd041.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="支付宝支付对接"/></a><div class="content"><a class="title" href="/page/Alipay.html" title="支付宝支付对接">支付宝支付对接</a><time datetime="2021-04-27T16:00:00.000Z" title="发表于 2021-04-28 00:00:00">2021-04-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/Vuejs11.html" title="Vue.js前端框架🎯Pagination+PageHelper实现分页"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@61bf4245f6d84d2d0f66d163b89c916788cc1845/2021/04/13/ec6b232f8fe5a840e4bd8c3eabcf49b2.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="Vue.js前端框架🎯Pagination+PageHelper实现分页"/></a><div class="content"><a class="title" href="/page/Vuejs11.html" title="Vue.js前端框架🎯Pagination+PageHelper实现分页">Vue.js前端框架🎯Pagination+PageHelper实现分页</a><time datetime="2021-04-26T14:48:39.701Z" title="发表于 2021-04-26 22:48:39">2021-04-26</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/page/Vuejs10.html" title="Vue.js前端框架🎯Vue-Element-admin模版"><img src="https://cdn.jsdelivr.net/gh/xiaoliblog/image@61bf4245f6d84d2d0f66d163b89c916788cc1845/2021/04/13/ec6b232f8fe5a840e4bd8c3eabcf49b2.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/lzyblog/image@main/2020/11/19/bd16b394f7359083b1f6072a67e3f968.png'" alt="Vue.js前端框架🎯Vue-Element-admin模版"/></a><div class="content"><a class="title" href="/page/Vuejs10.html" title="Vue.js前端框架🎯Vue-Element-admin模版">Vue.js前端框架🎯Vue-Element-admin模版</a><time datetime="2021-04-19T16:00:00.000Z" title="发表于 2021-04-20 00:00:00">2021-04-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By 小李博客</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">🎯Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">🎉Butterfly</a></div><div class="footer_custom_text"><span><a style="margin-inline:5px" target="_blank" href="https://hexo.io/"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo" title="博客框架为Hexo"></a><a style="margin-inline:5px" target="_blank" href="https://butterfly.js.org/"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender" title="主题采用butterfly"></a><a style="margin-inline:5px" target="_blank" href="https://www.jsdelivr.com/"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr" title="本站使用JsDelivr为静态资源提供CDN加速"></a><a style="margin-inline:5px" target="_blank" href="https://vercel.com/ "><img src="https://img.shields.io/badge/Hosted-Vercel-brightgreen?style=flat&logo=Vercel" title="本站采用双线部署，默认线路托管于Vercel"></a><a style="margin-inline:5px" target="_blank" href="https://coding.net/ "><img src="https://img.shields.io/badge/Hosted-Coding-0cedbe?style=flat&logo=Codio" title="本站采用双线部署，联通线路托管于Coding"></a><a style="margin-inline:5px" target="_blank" href="https://github.com/"><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&logo=GitHub" title="本站项目由Gtihub托管"></a><a style="margin-inline:5px" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&logo=Claris" title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可"></a></span></div><div class="icp"><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/"><img class="icp-icon" src="/img/icp.png" alt="ICP"/><span>湘ICP备2021002541号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><div class="search-dialog__title" id="algolia-search-title">Algolia</div><div id="algolia-input-panel"><div id="algolia-search-input"></div></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-stats"></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script><script src="/js/main.js"></script><script defer src="/js/tw_cn.js"></script><script defer src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module" defer></script><script defer src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script defer src="/js/search/algolia.js"></script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    loader: {
      source: {
        '[tex]/amsCd': '[tex]/amscd'
      }
    },
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        addClass: [200,() => {
          document.querySelectorAll('mjx-container:not([display=\'true\']').forEach( node => {
            const target = node.parentNode
            if (!target.classList.contains('has-jax')) {
              target.classList.add('mathjax-overflow')
            }
          })
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script><script>(()=>{
  const $countDom = document.getElementById('twikoo-count')
  const init = () => {
    twikoo.init(Object.assign({
      el: '#twikoo-wrap',
      envId: 'xiaoliblog-8gj3j5045d5b0896',
      region: ''
    }, null))
  }

  const getCount = () => {
    twikoo.getCommentsCount({
      envId: 'xiaoliblog-8gj3j5045d5b0896',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(function (res) {
      $countDom.innerText = res[0].count
    }).catch(function (err) {
      console.error(err);
    });
  }

  const loadTwikoo = (bool = false) => {
    if (typeof twikoo === 'object') {
      init()
      bool && $countDom && setTimeout(getCount,0)
    } else {
      getScript('https://cdn.jsdelivr.net/npm/twikoo@1.3.0/dist/twikoo.all.min.js').then(()=> {
        init()
        bool && $countDom && setTimeout(getCount,0)
      })
    }
  }

  if ('Twikoo' === 'Twikoo' || !true) {
    if (true) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo(true)
  } else {
    window.loadOtherComment = () => {
      loadTwikoo()
    }
  }
})()</script></div><script defer src="//lib.baomitu.com/jquery/3.5.1/jquery.min.js"></script><script defer src="https://myhkw.cn/api/player/160561664166" id="myhk" key="160561664166" m="1"></script><div><canvas id="snow" style="position:fixed;top:0;left:0;width:100%;height:100%;z-index:99999;pointer-events:none"></canvas></div><script>const notMobile = (!(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)));</script><scrip async type="text/javascript" src="https://cdn.jsdelivr.net/gh/Candinya/Kratos-Rebirth@latest/source/js/snow.min.js"></scrip><scrip defer src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@latest/source/js/issues.min.js"></scrip><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><script>var gitcalendar = new Vue({
  el: '#gitcalendar',
  data: {
    simplemode: true, 
    user: 'xiaoliblog',
    fixed: 'fixed',
    px: 'px',
    x: '',
    y: '',
    span1: '',
    span2: '',
    month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
    monthchange: [],
    oneyearbeforeday: '',
    thisday: '',
    amonthago: '',
    aweekago: '',
    weekdatacore: 0,
    datacore: 0,
    total: 0,
    datadate: '',
    data: [],
    positionplusdata: [],
    firstweek: [],
    lastweek: [],
    beforeweek: [],
    thisweekdatacore: 0,
    mounthbeforeday: 0,
    mounthfirstindex: 0,
    crispedges: 'crispedges',
    thisdayindex: 0,
    amonthagoindex: 0,
    amonthagoweek: [],
    firstdate: [],
    first2date: [],
    montharrbefore: [],
    monthindex: 0,
    color: ['#ebedf0', '#f1f8ff', '#dbedff', '#c8e1ff', '#79b8ff', '#2188ff', '#0366d6', '#005cc5', '#044289', '#032f62', '#05264c']
  },
  methods: {
    selectStyle(data, event) {
      document.querySelector('.angle-wrapper').style.display = 'block'
      this.span1 = data.date;
      this.span2 = data.count;
      this.x = event.clientX - 100;
      this.y = event.clientY - 60
    },
    outStyle() {
      document.querySelector('.angle-wrapper').style.display = 'none'
    },
    thiscolor(x) {
      if (x === 0) {
        let i = parseInt(x / 2);
        return this.color[0]
      } else if (x < 2) {
        return this.color[1]
      } else if (x < 20) {
        let i = parseInt(x / 2);
        return this.color[i]
      } else {
        return this.color[9]
      }
    },
  }
});
var apiurl = 'python-github-calendar-api-ruby.vercel.app' ? 'https://python-github-calendar-api-ruby.vercel.app/api?' : 'https://githubapi.ryanchristian.dev/user/'
var githubapiurl = apiurl + gitcalendar.user;
//canvas绘图
function responsiveChart() {
  let c = document.getElementById("gitcanvas");
  if (c) {
    let cmessage = document.getElementById("gitmessage");
    let ctx = c.getContext("2d");
    c.width = document.getElementById("gitcalendarcanvasbox").offsetWidth;
    let linemaxwitdh = 0.96 * c.width / gitcalendar.data.length;
    c.height = 9 * linemaxwitdh;
    let lineminwitdh = 0.8 * linemaxwitdh;
    let setposition = {
      x: 0.02 * c.width,
      y: 0.025 * c.width
    };
    for (let week in gitcalendar.data) {
      weekdata = gitcalendar.data[week];
      for (let day in weekdata) {
        let dataitem = {
          date: "",
          count: "",
          x: 0,
          y: 0
        };
        gitcalendar.positionplusdata.push(dataitem);
        ctx.fillStyle = gitcalendar.thiscolor(weekdata[day].count);
        setposition.y = Math.round(setposition.y * 100) / 100;
        dataitem.date = weekdata[day].date;
        dataitem.count = weekdata[day].count;
        dataitem.x = setposition.x;
        dataitem.y = setposition.y;
        ctx.fillRect(setposition.x, setposition.y, lineminwitdh, lineminwitdh);
        setposition.y = setposition.y + linemaxwitdh
      };
      setposition.y = 0.025 * c.width;
      setposition.x = setposition.x + linemaxwitdh
    };
    ctx.font = "600  Arial";
    ctx.fillStyle = '#aaa';
    ctx.fillText("日", 0, 1.9 * linemaxwitdh);
    ctx.fillText("二", 0, 3.9 * linemaxwitdh);
    ctx.fillText("四", 0, 5.9 * linemaxwitdh);
    ctx.fillText("六", 0, 7.9 * linemaxwitdh);
    let monthindexlist = c.width / 24;
    for (let index in gitcalendar.monthchange) {
      ctx.fillText(gitcalendar.monthchange[index], monthindexlist, 0.7 * linemaxwitdh);
      monthindexlist = monthindexlist + c.width / 12
    };
    cmessage.onmousemove = function(event) {
      document.querySelector('.angle-wrapper').style.display = 'none'
    };
    c.onmousemove = function(event) {
      document.querySelector('.angle-wrapper').style.display = 'none'
      getMousePos(c, event);
    };

    function getMousePos(canvas, event) {
      var rect = canvas.getBoundingClientRect();
      var x = event.clientX - rect.left * (canvas.width / rect.width);
      var y = event.clientY - rect.top * (canvas.height / rect.height);
      //console.log("x:"+x+",y:"+y);
      for (let item of gitcalendar.positionplusdata) {
        let lenthx = x - item.x;
        let lenthy = y - item.y;
        //console.log(lenthx,lenthy);
        if (0 < lenthx && lenthx < lineminwitdh) {
          if (0 < lenthy && lenthy < lineminwitdh) {
            //console.log(item.date,item.count)
            document.querySelector('.angle-wrapper').style.display = 'block'
            gitcalendar.span1 = item.date;
            gitcalendar.span2 = item.count;
            gitcalendar.x = event.clientX - 100;
            gitcalendar.y = event.clientY - 60
          }
        }
        //if(0< x - item.x <lineminwitdh&&0< y - item.y <lineminwitdh){
        //console.log(item.count,item.date);
        //}
      }
    }
  }
}
//数据统计算法
function addlastmonth() {
  if (gitcalendar.thisdayindex === 0) {
    thisweekcore(52);
    thisweekcore(51);
    thisweekcore(50);
    thisweekcore(49);
    thisweekcore(48);
    gitcalendar.thisweekdatacore += gitcalendar.firstdate[6].count;
    gitcalendar.amonthago = gitcalendar.firstdate[6].date
  } else {
    thisweekcore(52);
    thisweekcore(51);
    thisweekcore(50);
    thisweekcore(49);
    thisweek2core();
    gitcalendar.amonthago = gitcalendar.first2date[gitcalendar.thisdayindex - 1].date
  }
};

function thisweek2core() {
  for (let i = gitcalendar.thisdayindex - 1; i < gitcalendar.first2date.length; i++) {
    gitcalendar.thisweekdatacore += gitcalendar.first2date[i].count
  }
};

function thisweekcore(index) {
  for (let item of gitcalendar.data[index]) {
    gitcalendar.thisweekdatacore += item.count
  }
};

function addlastweek() {
  for (let item of gitcalendar.lastweek) {
    gitcalendar.weekdatacore += item.count
  }
};

function addbeforeweek() {
  for (let i = gitcalendar.thisdayindex; i < gitcalendar.beforeweek.length; i++) {
    gitcalendar.weekdatacore += gitcalendar.beforeweek[i].count
  }
};

function addweek(data) {
  if (gitcalendar.thisdayindex === 6) {
    gitcalendar.aweekago = gitcalendar.lastweek[0].date;
    addlastweek()
  } else {
    lastweek = data.contributions[51];
    gitcalendar.aweekago = lastweek[gitcalendar.thisdayindex + 1].date;
    addlastweek();
    addbeforeweek()
  }
}

fetch(githubapiurl)
  .then(data => data.json())
  .then(data => {
    gitcalendar.data = data.contributions;
    gitcalendar.total = data.total;
    gitcalendar.first2date = gitcalendar.data[48];
    gitcalendar.firstdate = gitcalendar.data[47];
    gitcalendar.firstweek = data.contributions[0];
    gitcalendar.lastweek = data.contributions[52];
    gitcalendar.beforeweek = data.contributions[51];
    gitcalendar.thisdayindex = gitcalendar.lastweek.length - 1;
    gitcalendar.thisday = gitcalendar.lastweek[gitcalendar.thisdayindex].date;
    gitcalendar.oneyearbeforeday = gitcalendar.firstweek[0].date;
    gitcalendar.monthindex = gitcalendar.thisday.substring(5, 7) * 1;
    gitcalendar.montharrbefore = gitcalendar.month.splice(gitcalendar.monthindex, 12 - gitcalendar.monthindex);
    gitcalendar.monthchange = gitcalendar.montharrbefore.concat(gitcalendar.month);
    addweek(data);
    addlastmonth();
    responsiveChart();
  })
  .catch(function(error) {
    console.log(error);
  });

//手机版更换为svg绘制
if (document.getElementById("gitcalendarcanvasbox").offsetWidth < 500) {
  gitcalendar.simplemode = false
}

//当改变窗口大小时重新绘制canvas
window.onresize = function() {
  if (gitcalendar.simplemode) responsiveChart()
}

//解决滚动滑轮时出现的标签显示
window.onscroll = function() {
  if (document.querySelector('.angle-wrapper')) {
    document.querySelector('.angle-wrapper').style.display = 'none'
  }
};</script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"react":{"opacity":0.7}});</script></body></html>